﻿
/*
*   描述：主控信道监视
*   编写：qfkong
*   时间：2011.06.21 16:30
*/

var tbsStr = ''; //基站ID字符串
var tbsIDList = []; //基站ID数组
var baseData = []; //基本信道详细数据
var left = 10;
var top = 10;
Ext.BLANK_IMAGE_URL = '../JS/ext-3.0.0/resources/images/default/s.gif';
Ext.QuickTips.init(); //  浮动信息提示
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());


function reLoadGrid() {
    try {
        AjaxGetData();
        for (var i = 0, length = tbsIDList.length; i < length; i++) {
            addPannel(tbsIDList[i]);
        }
    } catch (e) {
    }
}



/*添加窗口*/
function addPannel(winid,isAdd) {
    var w = Ext.getCmp('win' + winid);
    getTBSID();
    AjaxGetData();
    var d = getData(winid);
    if (d) {
        var t = d.TBSNAME + '&nbsp;&nbsp;' + d.TIMESTAMP.format('H:i:s') + '&nbsp;上行&nbsp;'
    + d.MCCH_UPLINK_USAGE + '%&nbsp;&nbsp;下行&nbsp;' + d.MCCH_DOWNLINK_USAGE + '%';
        if (w) {
            if (isAdd == false) {
                w.hide();
            }
            else {
                w.setTitle(t);
                w.show();
                var gridtmp = Ext.getCmp('grid_' + winid);
                var store = gridtmp.getStore();
                try {
                    cm.config[0].header = t;
                    store.loadData(d);
                    gridtmp.reconfigure(store, cm);
                } catch (e) {
                } 
            }
        }
        else {
            console.log(winid, t, d);
            var win = createWindow(winid, t, d);
            var p = Ext.getCmp('panel_main');
            if (p) {
                p.add(win);
                p.doLayout(true);
                win.setPosition(d.LEFT, d.TOP);
                win.show();
                win.on('hide', function (w) {
                    //var s = w.id.split('_');
                    //setNodeUnCheck(s[1]);
                });
            }
           
        }
    }
}
/*根据ID获取数据*/
function getData(tbsid) {
    if (baseData) {
        for (var i = 0, length = baseData.length; i < length; i++) {
            if (baseData[i].NEID == tbsid) {
                return baseData[i];
            }
        }
    }
}
/*初始化页面*/
function initPage() {
    var el = Ext.getDom('InformationCurrentStation');
    el.style.height = window.screen.height - 100 + 'px';
    createPanel();
    getTBSID();
    AjaxGetData();
    for (var i = 0, length = tbsIDList.length; i < length; i++) {
        addPannel(tbsIDList[i]);
    }
}
/*处理TBSID字符串*/
function getTBSID() {
    var s = window.parent.GetCookie('zhwg_TBSMainChannel');
    tbsStr = s;
    if (tbsStr) {
        if (tbsStr.lastIndexOf(',') == tbsStr.length - 1) {
            tbsStr = tbsStr.substring(0, tbsStr.length - 1);
        }
        tbsIDList = tbsStr.split(',');
    }
}
/*异步获取数据*/
function AjaxGetData() {
    if (tbsStr) {
        if (tbsStr.lastIndexOf(',') == tbsStr.length - 1) {
            tbsStr = tbsStr.substring(0, tbsStr.length - 1);
        }
        var myData = Topo_ChannelDetail.GetMainChanelList(tbsStr.replace(/,/g, '\',\'')).value;
        console.log("加载数据", myData);
        SpiltData(myData);
    }
}

/*分割数据,将一条数据分割成八个载波*/
function SpiltData(dt) {
    if (dt && dt.Rows) {
        var dd = [];
        for (var i = 0, length = dt.Rows.length; i < length; i++) {
            dd = [];
            dd.push({ TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX1'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-0',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX1_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX1_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX1_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX1_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX1_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX1_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX1_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX1_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX1_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX1_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX1_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX1_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            dd.push({
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX2'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-1',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX2_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX2_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX2_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX2_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX2_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX2_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX2_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX2_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX2_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX2_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX2_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX2_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            dd.push({
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX3'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-2',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX3_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX3_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX3_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX3_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX3_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX3_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX3_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX3_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX3_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX3_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX3_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX3_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            dd.push({
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX4'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-3',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX4_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX4_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX4_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX4_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX4_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX4_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX4_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX4_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX4_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX4_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX4_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX4_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            dd.push({
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX5'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-4',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX5_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX5_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX5_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX5_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX5_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX5_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX5_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX5_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX5_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX5_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX5_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX5_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            dd.push({
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX6'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-5',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX6_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX6_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX6_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX6_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX6_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX6_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX6_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX6_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX6_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX6_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX6_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX6_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            dd.push({
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX7'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-6',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX7_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX7_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX7_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX7_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX7_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX7_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX7_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX7_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX7_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX7_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX7_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX7_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            dd.push({
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                TTRX: dt.Rows[i]['TTRX8'],
                TTRXNAME: dt.Rows[i]['TBSNUMBER'] + '-7',
                USAGE_TYPE_SLOT1: dt.Rows[i]['TTRX8_SLOT1_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT1: dt.Rows[i]['TTRX8_SLOT1_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT1: dt.Rows[i]['TTRX8_SLOT1_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT2: dt.Rows[i]['TTRX8_SLOT2_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT2: dt.Rows[i]['TTRX8_SLOT2_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT2: dt.Rows[i]['TTRX8_SLOT2_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT3: dt.Rows[i]['TTRX8_SLOT3_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT3: dt.Rows[i]['TTRX8_SLOT3_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT3: dt.Rows[i]['TTRX8_SLOT3_RESERVER_ORGANISATION'],
                USAGE_TYPE_SLOT4: dt.Rows[i]['TTRX8_SLOT4_CHANNEL_USAGE_TYPE'],
                RESERVER_SSI_SLOT4: dt.Rows[i]['TTRX8_SLOT4_RESERVER_SSI'],
                RESERVER_ORGANISATION_SLOT4: dt.Rows[i]['TTRX8_SLOT4_RESERVER_ORGANISATION'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                CHANNEL_QUEUE_LENGTH: dt.Rows[i]['CHANNEL_QUEUE_LENGTH']
            });
            baseData.push({ NEID: dt.Rows[i]['NE_ID'],
                data: dd,
                TBSNAME: dt.Rows[i]['CHINA_NAME'],
                MCCH_UPLINK_USAGE: dt.Rows[i]['MCCH_UPLINK_USAGE'],
                MCCH_DOWNLINK_USAGE: dt.Rows[i]['MCCH_DOWNLINK_USAGE'],
                TIMESTAMP: dt.Rows[i]['REPORT_TIMESTAMP'],
                LEFT: 30 + 450 * parseInt(i % 2),
                TOP: 10 + 450 * parseInt(i / 2)
            });
            console.log('left=' + baseData[i].LEFT + ',top=' + baseData[i].TOP);
        }
    }
}
/*创建基本容器*/
function createPanel() {
    var h = Ext.get('InformationCurrentStation');
    new Ext.Panel({
        renderTo: 'InformationCurrentStation',
        //border: true,
        id: 'panel_main',
        //layout: 'table',
        //layoutConfig: { columns: 3 }, //将父容器分成3列
        autoScroll: true,
        height: h.getHeight() ,
        width: h.getWidth()
    });
}

/*
*   创建窗口
*/
function createWindow(id, title, d) {
    //    cm = createColumn();
    //    gridData = createStore();
    //    gridData.load();
    //gridid = 'grid_' + id;
    return new Ext.Window({
        //renderTo: 'InformationCurrentStation',
        width: 420,
        height: 440,
        id: 'win' + id,
        resizable: true,
        collapsible: true,
        closeAction: 'hide', //关闭时的动作 hide或close
        autoScroll: true,
        //forceLayout:true,
        //draggable: false,
        //layout: 'column', //布局方式  其他还有column,from,table,fit 等等
        //minimizable:true,
        items: createGridPanel('grid_' + id, d),
        plain: false, //true则主体背景透明，false则主体有小差别的背景色，默认为false
        title: title
    });
}

/*
*   创建GridPanel
*   @param  id  GridPanel ID
*/
function createGridPanel(id, data) {
    var cm = new Ext.grid.ColumnModel({ defaults: { width: 50, height: 100, sortable: true, menuDisabled: true }, columns: [
                       { id: 'TTRX', header: '', align: 'center', width: 30, css: 'vertical-align :middle;', dataIndex: 'TTRXNAME' },
                       { header: 'TSL0', renderer: formatData, dataIndex: 'USAGE_TYPE_SLOT1' },
                       { header: 'TSL1', renderer: formatData, dataIndex: 'USAGE_TYPE_SLOT2' },
                       { header: 'TSL2', renderer: formatData, dataIndex: 'USAGE_TYPE_SLOT3' },
                       { header: 'TSL3', renderer: formatData, dataIndex: 'USAGE_TYPE_SLOT4' }
            ]
    });
    var reader = new Ext.data.ArrayReader({}, new Ext.data.Record.create([
                        { name: "TTRX", mapping: "TTRX", type: "string" },
                        { name: "TTRXNAME", mapping: "TTRXNAME", type: "string" },
                        { name: "USAGE_TYPE_SLOT1", mapping: "USAGE_TYPE_SLOT1", type: "string" },
                        { name: "RESERVER_SSI_SLOT1", mapping: "RESERVER_SSI_SLOT1", type: "string" },
                        { name: "RESERVER_ORGANISATION_SLOT1", mapping: "RESERVER_ORGANISATION_SLOT1", type: "string" },
                        { name: "USAGE_TYPE_SLOT2", mapping: "USAGE_TYPE_SLOT2", type: "string" },
                        { name: "RESERVER_SSI_SLOT2", mapping: "RESERVER_SSI_SLOT2", type: "string" },
                        { name: "RESERVER_ORGANISATION_SLOT2", mapping: "RESERVER_ORGANISATION_SLOT2", type: "string" },
                        { name: "USAGE_TYPE_SLOT3", mapping: "USAGE_TYPE_SLOT3", type: "string" },
                        { name: "RESERVER_SSI_SLOT3", mapping: "RESERVER_SSI_SLOT3", type: "string" },
                        { name: "RESERVER_ORGANISATION_SLOT3", mapping: "RESERVER_ORGANISATION_SLOT3", type: "string" },
                        { name: "USAGE_TYPE_SLOT4", mapping: "USAGE_TYPE_SLOT4", type: "string" },
                        { name: "RESERVER_SSI_SLOT4", mapping: "RESERVER_SSI_SLOT4", type: "string" },
                        { name: "RESERVER_ORGANISATION_SLOT4", mapping: "RESERVER_ORGANISATION_SLOT4", type: "string" },
                        { name: "MCCH_UPLINK_USAGE", mapping: "MCCH_UPLINK_USAGE", type: "string" },
                        { name: "MCCH_DOWNLINK_USAGE", mapping: "MCCH_DOWNLINK_USAGE", type: "string" },
                        { name: "CHANNEL_QUEUE_LENGTH", mapping: "CHANNEL_QUEUE_LENGTH", type: "string" }
                    ]));

    var gridData = new Ext.data.Store({
        proxy: new Ext.data.MemoryProxy(data.data),
        reader: reader
    });
    gridData.load();
    return new Ext.grid.GridPanel({
        store: gridData, //数据内容
        cm: cm, //表头        
        id: id,
        enableHdMenu: true,
        columnLines: true,
        /*stripeRows: true,*/
        width: 400,
        height: 400,
        viewConfig: { forceFit: true },
        loadMask: new Ext.LoadMask(Ext.getBody(), { msg: "正在加载数据，请稍后..." })//, // 加载数据时遮蔽表格
    });
}

function formatData(val, e, record, rowIndex, colIndex, store) {
    var strHTML = '';
    var ut = record.json['USAGE_TYPE_SLOT' + colIndex];
    var usageType = ut; // (ut == 'Main control channel' ? 'MCCH' : (ut.indexOf('Traffic channel') == 0 ? 'EMG' : (ut == 'Radio channel is free' ? 'TCH' : (ut == 'Not usable' ? 'NA' : 'IDLE'))));
    /*
    *   描述：占用类型颜色配置
    *   如果界面颜色不对，可适当修改对应颜色
    *   颜色配对： MCCH(#FF00FF),TCH(#FFC000),NA(gray),其他类型(#92D050),如果有需要可增加类型及对应颜色
    *   编写：qfkong
    *   时间：2011.06.22 10:06
    */
    var strStyle = 'width:100%;height:100%; padding:3px; background-color:' + (usageType == 'MCCH' ? '#FF00FF' : (usageType == 'TCH' ? '#FFC000' : (usageType == 'NA' ? 'gray' : '#92D050'))) + ';';
    if (usageType == 'MCCH') {
        //        strHTML = '<div style="' + strStyle + '">占用类型：' + usageType + '<br/>上行占用率：' + (record.json.MCCH_UPLINK_USAGE || 0) + '%';
        //        strHTML += '<br />下行占用率：' + (record.json.MCCH_UPLINK_USAGE || 0) + '%<br />排队数量：' + (record.json.CHANNEL_QUEUE_LENGTH || 0);
        strHTML = '<div style="' + strStyle + '">' + usageType + '<br />' + (record.json.CHANNEL_QUEUE_LENGTH || 0);
    }
    else if (usageType == 'NA') {
        strHTML = '<div style="' + strStyle + '">' + usageType + '<br />&nbsp;<br />&nbsp;<br />&nbsp;';
    }
    else {
        //        strHTML = '<div style="' + strStyle + '">占用类型：' + usageType + '<br/>使用号码：' + (record.json['RESERVER_SSI_SLOT' + colIndex] || '');
        //        strHTML += '<br />组织块：' + (record.json['RESERVER_ORGANISATION_SLOT' + colIndex] || '') + '<br />&nbsp;';
        strHTML = '<div style="' + strStyle + '">' + usageType + '<br/>' + (record.json['RESERVER_SSI_SLOT' + colIndex] || '') + '<br />' + (record.json['RESERVER_ORGANISATION_SLOT' + colIndex] || '');
    }
    return strHTML + '</div>';
}



initPage();

setInterval(reLoadGrid, 90000); //界面90秒钟更新一次数据